package point

import (
	"fmt"
	"os"
)

type CpuTemplatePoint struct{}

func NewCpuTemplatePoint() *CpuTemplatePoint { return &CpuTemplatePoint{} }

func (c *CpuTemplatePoint) Get() any {
	f, err := os.Open("/sys/class/thermal/thermal_zone0/temp")
	if err != nil {
		return 0
	}

	defer f.Close()

	var temp int = 0
	fmt.Fscanf(f, "%d", &temp)
	return float64(temp) * 0.001
}

func (c *CpuTemplatePoint) Set(...any) bool { return false }

func (c *CpuTemplatePoint) SetRoute(string) PointInterface { return c }
